package com.nms.util;

import java.util.Map;

import com.nms.model.News;
import com.nms.model.User;
import com.opensymphony.xwork2.ActionContext;

public class UserLoginUtil {

	private static UserLoginUtil util = null;
	static {
		util = new UserLoginUtil();
	}
	private UserLoginUtil(){}
	public static UserLoginUtil getInstance(){
		return util;
	}

	public synchronized boolean isLogineds() {
		Map<String, Object> session = ActionContext.getContext().getSession();
		User u = (User) session.get("user");
		return u != null;
	}
	public synchronized boolean isExceed() {
		Map<String, Object> session = ActionContext.getContext().getSession();
		User u = (User) session.get("user");
//		if(u.getRole().getId() == 5)
//			return true;
		System.out.println("user is null ??? -> " + u == null);
		return u == null;
	}
	public void copyNews(News src,News object){
		object.setId(src.getId());
		object.setActiveTime(src.getActiveTime());
		object.setAssistTitle(src.getAssistTitle());
		object.setBackground(src.getBackground());
		object.setCommentCount(src.getCommentCount());
		object.setConcernCount(src.getConcernCount());
		object.setConclusion(src.getConclusion());
		object.setContent(src.getContent());
		object.setDegree(src.getDegree());
		object.setIntroduction(src.getIntroduction());
		object.setKeyword(src.getKeyword());
		object.setMainTitle(src.getMainTitle());
		object.setOrigin(src.getOrigin());
		object.setPublisher(src.getPublisher());
		object.setRebroadcast(src.getRebroadcast());
		object.setReleaseTime(src.getReleaseTime());
		object.setSubTitle(src.getSubTitle());
		object.setType(src.getType());
	
	}
}
